package com.dzsw.netty.hb;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class ProtobuffBizHandler extends SimpleChannelInboundHandler<CProtocol.Message> {

    @Override
    protected void channelRead0(ChannelHandlerContext ctx, CProtocol.Message msg) throws Exception {
        log.info(" ====== > [ProtobuffBizHandler] Biz received : " + msg.getRequest().getMsg());
        CProtocol.Response.Builder builder = CProtocol.Response.newBuilder();
        builder.setStatus(200);
        builder.setMsg("success!");
        builder.setData("");
        ctx.channel().writeAndFlush(ProtobufUtils.createMessage(builder.build()));
    }
}
